package com.application;

import android.os.Bundle;
import android.view.View;

import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.launcher.ARouter;
import com.application.databinding.ActivityLiveEventBusBinding;
import com.application.util.ARouterConstants;
import com.jeremyliao.liveeventbus.LiveEventBus;

@Route(path = ARouterConstants.ACTIVITY_URL_LIVE_EVENT_BUS)
public class LiveEventBusActivity extends AppCompatActivity {

    private ActivityLiveEventBusBinding binding;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        binding= DataBindingUtil.setContentView(this,R.layout.activity_live_event_bus);
        binding.setActivity(this);
        binding.setResultText(getString(R.string.Unsubscribed));

        LiveEventBus.get("subResult",String.class)
                .observe(this, s -> binding.setResultText(s));

    }

    public void startLiveEventBus(View view) {
        ARouter.getInstance()
                .build(ARouterConstants.ACTIVITY_URL_LIVE_EVENT_BUS_SUB)
                .navigation();
    }
}